const mongoose = require('mongoose');

// 字典项 Schema
const dictItemSchema = new mongoose.Schema({
    label: {
        type: String,
        required: [true, '标签名称必填'],
        trim: true,
        description: '标签名称',
         description: '标签名'
    },
    value: {
        type: String,
        required: [true, '值必填'],
        trim: true,
        description: '值',
    },
    sort: {
        type: Number,
        default: 0,
        description: '排序'
    },
    status: {
        type: Boolean,
        default: true,
        description: '状态'
    }
});

// 字典 Schema
const dictSchema = new mongoose.Schema({
    name: {
        type: String,
        required: [true, '字典名称必填'],
        unique: true,
        trim: true,
        description: '字典名称'
    },
    description: {
        type: String,
        trim: true,
        description: '字典描述'
    },
    items: [dictItemSchema],
    status: {
        type: Boolean,
        default: true,
        description: '状态'
    }
}, {
    timestamps: true
});

module.exports = mongoose.model('Dict', dictSchema); 